package com.gupaoedu.design.observer.proxy.core;

/**
 * <p></p>
 *
 * @author Andy
 * @date 2018/3/21.
 */
public enum EventType {
    ON_ADD(1,"add"),
    ON_EDIT(2,"edit"),
    ON_REMOVE(3,"remove"),
    ON_QUERY(4,"query");

    private int id;
    private String cname;

    EventType(int id, String cname) {
        this.id = id;
        this.cname = cname;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getCname() {
        return cname;
    }

    public void setCname(String cname) {
        this.cname = cname;
    }

    public static String getCnameByKey(int id) {
        for (EventType type : EventType.values()) {
            if (type.getId() == id) return type.getCname();
        }
        return "";
    }

    public static EventType getStatusByKey(int id) {
        for (EventType type : EventType.values()) {
            if (type.getId() == id) return type;
        }
        return null;
    }

    public static EventType getStatusByName(String cname) {
        for (EventType type : EventType.values()) {
            if (type.getCname().equals(cname)) return type;
        }
        return null;
    }
}
